<template>
  <div class="index" >
    <div class="item" @click="h5Scan" id="scan">点击扫码</div>
    <div class="item">扫码结果：</div>
    <div class="item" id="result"></div>
  </div>
</template>

<script type="text/ecmascript-6">
  export default {
    components: {
    },
    data() {
      return {

      }
    },
    methods: {
      h5Scan() {
        this.wccia.goScan(function(params) {
          if (params) {
            if (typeof params === 'string') {
              params = JSON.parse(params)
            }
            var div=document.getElementById("result");
            div.innerHTML = '类型：'+ params.type + '<br>' + '扫码结果：' + params.code + '<br>' + '彩虹码：' + params.rainbowcode
          }
        })
      }
    },
    created() {
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  .index
    display block
    height 6rem
    line-height 6rem
    .item
      height .6rem
      line-height .6rem
      font-size .4rem
      margin .5rem 0 .5rem 0
      &#scan
        text-align center
        font-size .5rem
        border-radius .05rem
        padding .2rem
        background  #ff0000
</style>
